<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" ></script>
<script src="/js/gu.js" type="text/javascript" ></script>
<script>

intr = null;

function searchFor(){
  
  word = $('#word').attr('value');
  url = $('#url').attr('value');
  
  if(intr != null)
    clearInterval(intr);
  $("#status").html("Searching: word: "+ word +" in url: http://"+url);
  count =0;
  intr = setInterval(function(){
    $("#status").html("Searching: word: "+ word +" in url: http://"+url+" look "+ count +" times");
    count += 1;
    ajax("GET","/string-search-word","word="+word+"&url="+url,function(res){
       //alert('ye');
       if(res.indexOf(word) != -1){
         alert('the word was found');
         StopSearch();
       }
       else{
         //alert('no ' + res);
       }
    });
  },3000)
}


function StopSearch(){
  clearInterval(intr);
  $("#status").html("Stop Searching")
}

</script>

<h2>Just type the word you are looking in the url(address) and the moment
  the word will be found you will get an alert, keep this page open while searching</h2>

Word :<input id="word" value='a'/><br/>
Url :<input id="url" value='google.com'/><br/>
<button onclick="searchFor()">Search</button><br/>
<button onclick="StopSearch()">Stop</button><br/>
<p id="status"></p>


